﻿using QuanLyBanHang.BLL;
using QuanLyBanHang.DTO;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QuanLyBanHang
{
    public partial class frmNhanVien : Form
    {
        public frmNhanVien()
        {
            InitializeComponent();
        }
        NhanVienDTO nv = new NhanVienDTO();
        private void button1_Click(object sender, EventArgs e)
        {
            TaoNhanVien();
            MessageBox.Show("Them thanh cong "+NhanVienBLL.ThemNV(nv));
            frmNhanVien_Load(sender, e);
        }
       

        private void button2_Click(object sender, EventArgs e)
        {
             TaoNhanVien();
            MessageBox.Show("Xóa Thành Công"+NhanVienBLL.XoaNV(nv));
            frmNhanVien_Load(sender, e);
        }

        private void button4_Click(object sender, EventArgs e)
        {
             TaoNhanVien();
            MessageBox.Show("Sua Thanh cong"+NhanVienBLL.SuaNV(nv));
            frmNhanVien_Load(sender, e);
        }
        private void TaoNhanVien()
        {
            NhanVienDTO.MaNV = textBox1.Text;
            NhanVienDTO.HoNV = textBox2.Text;
            NhanVienDTO.TenNV = textBox3.Text;
            NhanVienDTO.GioiTinh = comboBox1.Text;
            NhanVienDTO.NgaySinh = Convert.ToDateTime(dateTimePicker1.Text);
            NhanVienDTO.DiaChi = textBox5.Text;
            NhanVienDTO.DienThoai = textBox4.Text;
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int i = e.RowIndex;
          
            textBox1.Text = dataGridView1.Rows[i].Cells[0].Value.ToString();
            textBox2.Text = dataGridView1.Rows[i].Cells[1].Value.ToString();
            textBox3.Text = dataGridView1.Rows[i].Cells[2].Value.ToString();
            comboBox1.Text = dataGridView1.Rows[i].Cells[3].Value.ToString();
            dateTimePicker1.Text = dataGridView1.Rows[i].Cells[4].Value.ToString();
            textBox5.Text = dataGridView1.Rows[i].Cells[5].Value.ToString();
            textBox4.Text = dataGridView1.Rows[i].Cells[6].Value.ToString();

           
        }

        private void frmNhanVien_Load(object sender, EventArgs e)
        {
            dataGridView1.DataSource = NhanVienBLL.LayTatCaNV(nv);
        }
    }
}
